import CryptoJS from 'crypto-js';

const key = CryptoJS.enc.Utf8.parse("KingSystem.Net");
const iv = CryptoJS.enc.Utf8.parse("KingSystem.Net");

export function encrypt(textInfo){
    // console.log(textInfo)
    // console.log(key+"")
    let encrypted = CryptoJS.AES.encrypt(textInfo.toString(), key.toString(), {
        iv: iv.toString(),
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });

    return encrypted.toString();
}

export function decrypt(textInfo){
    let decrypted = CryptoJS.AES.decrypt(textInfo.toString(), key.toString(), {
        iv: iv.toString(),
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });

    return decrypted.toString(CryptoJS.enc.Utf8);
}
